package cn.javaeye.lonlysky.lforum.service;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springside.modules.orm.hibernate.SimpleHibernateTemplate;

import cn.javaeye.lonlysky.lforum.entity.web.FartherType;


@Service
@Transactional
public class FartherTypeManager {

	public SimpleHibernateTemplate<FartherType, Integer> getFartherTypeDAO() {
		return fartherTypeDAO;
	}


	public void setFartherTypeDAO(
			SimpleHibernateTemplate<FartherType, Integer> fartherTypeDAO) {
		this.fartherTypeDAO = fartherTypeDAO;
	}
	private SimpleHibernateTemplate<FartherType, Integer> fartherTypeDAO;

	@Autowired
	public void setSessionFactory(SessionFactory sessionFactory) {
		fartherTypeDAO = new SimpleHibernateTemplate<FartherType, Integer>(sessionFactory, FartherType.class);
	}


	/**
	 * 
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public List<FartherType> findByType(String type) {
		return fartherTypeDAO.find("from FartherType where type=?", type);
	}
	public List<FartherType> findAll() {
		return fartherTypeDAO.findAll();
	}

	public void createFartherType(FartherType fartherType) {
		fartherTypeDAO.save(fartherType);
	}
	public void remove(Integer id) {
		
		fartherTypeDAO.delete(id);
	}
	public FartherType get(Integer id) {
		
		return fartherTypeDAO.get(id);
	}

}
